%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/allRelationalTopics.orderBy"
    Bucket0("Bucket 0 (root)<br /><br />1: 65, 69<br />ᐳ: Access[9], Access[10], Object[11]<br />2: PgSelect[8], PgSelect[15]<br />ᐳ: Access[66], Access[70]<br />3: Connection[12], Connection[17]<br />4: 19, 22"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 19, 66<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 22, 70<br /><br />ROOT Connectionᐸ15ᐳ[17]"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 66<br /><br />ROOT __Item{5}ᐸ19ᐳ[25]"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 70<br /><br />ROOT __Item{6}ᐸ22ᐳ[27]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 66, 26<br /><br />ROOT PgSelectSingle{5}ᐸrelational_topicsᐳ[26]<br />1: <br />ᐳ: List[67], Lambda[68]<br />2: PgSelectRows[35]<br />ᐳ: 34, 36, 37, 52, 58, 64"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 70, 28<br /><br />ROOT PgSelectSingle{6}ᐸrelational_topicsᐳ[28]<br />1: <br />ᐳ: List[71], Lambda[72]<br />2: PgSelectRows[44]<br />ᐳ: 43, 45, 46"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket1 --> Bucket5
    Bucket2 --> Bucket6
    Bucket5 --> Bucket7
    Bucket6 --> Bucket8

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸrelational_topicsᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply65["PgSelectInlineApply[65∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply65 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    PgSelect15[["PgSelect[15∈0] ➊<br />ᐸrelational_topicsᐳ"]]:::plan
    PgSelectInlineApply69["PgSelectInlineApply[69∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply69 --> PgSelect15
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    Connection17[["Connection[17∈0] ➊<br />ᐸ15ᐳ"]]:::plan
    PgSelect15 --> Connection17
    ConnectionItems19[["ConnectionItems[19∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems19
    ConnectionItems22[["ConnectionItems[22∈0] ➊"]]:::plan
    Connection17 --> ConnectionItems22
    Access66{{"Access[66∈0] ➊<br />ᐸ8.m.joinDetailsFor30ᐳ"}}:::plan
    PgSelect8 --> Access66
    Access70{{"Access[70∈0] ➊<br />ᐸ15.m.joinDetailsFor39ᐳ"}}:::plan
    PgSelect15 --> Access70
    __Item25[/"__Item[25∈5]<br />ᐸ19ᐳ"\]:::itemplan
    ConnectionItems19 ==> __Item25
    PgSelectSingle26{{"PgSelectSingle[26∈5]<br />ᐸrelational_topicsᐳ"}}:::plan
    __Item25 --> PgSelectSingle26
    __Item27[/"__Item[27∈6]<br />ᐸ22ᐳ"\]:::itemplan
    ConnectionItems22 ==> __Item27
    PgSelectSingle28{{"PgSelectSingle[28∈6]<br />ᐸrelational_topicsᐳ"}}:::plan
    __Item27 --> PgSelectSingle28
    List67{{"List[67∈7]<br />ᐸ66,26ᐳ"}}:::plan
    Access66 & PgSelectSingle26 --> List67
    First34{{"First[34∈7]"}}:::plan
    PgSelectRows35[["PgSelectRows[35∈7]"]]:::plan
    PgSelectRows35 --> First34
    Lambda68{{"Lambda[68∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda68 --> PgSelectRows35
    PgSelectSingle36{{"PgSelectSingle[36∈7]<br />ᐸrelational_itemsᐳ"}}:::plan
    First34 --> PgSelectSingle36
    PgClassExpression37{{"PgClassExpression[37∈7]<br />ᐸ__relation...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle36 --> PgClassExpression37
    PgClassExpression52{{"PgClassExpression[52∈7]<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgClassExpression37 o--o PgClassExpression52
    PgClassExpression58{{"PgClassExpression[58∈7]<br />ᐸ__relation...reated_at”ᐳ"}}:::plan
    PgClassExpression52 o--o PgClassExpression58
    PgClassExpression64{{"PgClassExpression[64∈7]<br />ᐸ__relation...chived_at”ᐳ"}}:::plan
    PgClassExpression58 o--o PgClassExpression64
    List67 --> Lambda68
    List71{{"List[71∈8]<br />ᐸ70,28ᐳ"}}:::plan
    Access70 & PgSelectSingle28 --> List71
    First43{{"First[43∈8]"}}:::plan
    PgSelectRows44[["PgSelectRows[44∈8]"]]:::plan
    PgSelectRows44 --> First43
    Lambda72{{"Lambda[72∈8]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda72 --> PgSelectRows44
    PgSelectSingle45{{"PgSelectSingle[45∈8]<br />ᐸrelational_itemsᐳ"}}:::plan
    First43 --> PgSelectSingle45
    PgClassExpression46{{"PgClassExpression[46∈8]<br />ᐸ__relation...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle45 --> PgClassExpression46
    List71 --> Lambda72

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,PgSelect15,Connection17,ConnectionItems19,ConnectionItems22,PgSelectInlineApply65,Access66,PgSelectInlineApply69,Access70 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item25,PgSelectSingle26 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item27,PgSelectSingle28 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,First34,PgSelectRows35,PgSelectSingle36,PgClassExpression37,PgClassExpression52,PgClassExpression58,PgClassExpression64,List67,Lambda68 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,First43,PgSelectRows44,PgSelectSingle45,PgClassExpression46,List71,Lambda72 bucket8

